import { defineStore } from 'pinia'

// 拖动增加模型，当前正在新增的模型
export const useMeshEditStore = defineStore('useMeshEditStore', {
    state: () => ({
        // 当前模型
        modelApi: {},
        // 当前drag拖拽类型
        dragType: '',
        // 标签列表
        labelIns: {},
        // 当前正在导入的模型
        uploadModels: []
    }),
    getters: {
        meshPath: (state) => state.modelApi.path,
        meshTypeId: (state) => state.modelApi.id,
        labelList: (state) => state.labelIns.labelList
    },
    actions: {
        setModelApi(modelApi) {
            this.modelApi = modelApi
        },
        setLabelIns(labelIns) {
            this.labelIns = labelIns
        },
        changeDragType(dragType) {
            this.dragType = dragType
        },
        addUploadModel(model) {
            this.uploadModels.push(model)
        },
    }
})

// 标签列表
export const useLabelListStore = defineStore('useLabelListStore', {
    state: () => ({
        labelList: [],
    }),
    actions: {
        setLabelList(labelList) {
            this.labelList.splice(0, this.labelList.length)
            for (let i = 0; i < labelList.length; i++) {
                this.labelList.push(labelList[i])
            }
        }
    }
})

// 提交模型列表
export const formDataStore = defineStore('formDataStore', {
    state: () => ({
        commonModels: [],
        selfModels: [],
        pipes: [],
        labels: []
    }),
    actions: {
        setCommonModels(commonModels) {
            this.commonModels = commonModels
        },
        setSelfModels(selfModels) {
            this.selfModels = selfModels
        },
        setPipes(pipes) {
            this.pipes = pipes
        },
        setLabels(labels) {
            this.labels = labels
        },
    }
})